﻿(function ($) {
    $.fn.validationEngineLanguage = function () {
    };
    $.validationEngineLanguage = {
        newLang: function () {
            $.validationEngineLanguage.allRules = {
                "required": { // Add your regex rules here, you can take telephone as an example
                    "regex": "none",
                    "alertText": "* 字段必须填写",
                    "alertTextCheckboxMultiple": "* 请选择一项",
                    "alertTextCheckboxe": "* 复选框比选选定"
                },
                "minSize": {
                    "regex": "none",
                    "alertText": "* 至少 ",
                    "alertText2": " 个字符"
                },
                "maxSize": {
                    "regex": "none",
                    "alertText": "* 至多 ",
                    "alertText2": " 个字符"
                },
                "min": {
                    "regex": "none",
                    "alertText": "* 最小值 "
                },
                "max": {
                    "regex": "none",
                    "alertText": "* 最大值 "
                },
                "past": {
                    "regex": "none",
                    "alertText": "* 日期必须是过去的"
                },
                "future": {
                    "regex": "none",
                    "alertText": "* 日期必须是将来的 "
                },
                "maxCheckbox": {
                    "regex": "none",
                    "alertText": "* 选择过多"
                },
                "minCheckbox": {
                    "regex": "none",
                    "alertText": "* 请至少选择 ",
                    "alertText2": " 个选项"
                },
                "equals": {
                    "regex": "none",
                    "alertText": "* 字段不相等"
                },
                "phone": {
                    // credit: jquery.h5validate.js / orefalo
                    "regex": /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,
                    "alertText": "* 电话号码格式不正确"
                },
                "email": {
                    // Simplified, was not working in the Iphone browser
                    "regex": /^([A-Za-z0-9_\-\.\'])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,6})$/,
                    "alertText": "* Email 格式不正确"
                },
                "integer": {
                    "regex": /^[\-\+]?\d+$/,
                    "alertText": "* 不是一个合法的整形"
                },
                "number": {
                    // Number, including positive, negative, and floating decimal. credit: orefalo
                    "regex": /^[\-\+]?(([0-9]+)([\.,]([0-9]+))?|([\.,]([0-9]+))?)$/,
                    "alertText": "* 不是一个合法的浮点型"
                },
                "date": {
                    "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/,
                    "alertText": "* 日期格式错误, 正确的格式是 YYYY-MM-DD"
                },
                "ipv4": {
                    "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
                    "alertText": "* Ip地址格式不正确"
                },
                "url": {
                    "regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/,
                    "alertText": "* URL 格式不正确"
                },
                "onlyNumberSp": {
                    "regex": /^[0-9\ ]+$/,
                    "alertText": "* 只允许数字"
                },
                "onlyLetterSp": {
                    "regex": /^[a-zA-Z\ \']+$/,
                    "alertText": "* 只允许英文字符"
                },
                "onlyLetterNumber": {
                    "regex": /^[0-9a-zA-Z]+$/,
                    "alertText": "* 只允许英文字符和数字"
                },
                "postcalCode": {
                    "regex": /^\d{6}$/,
                    "alertText": "* 邮政编码格式不正确"
                },
                // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings
                "AjaxUsernameShouldntExist": {
                    "url": "/Account/AjaxUsernameShouldntExist",
                    // you may want to pass extra data on the ajax call
                    "extraData": "name=eric",
                    "alertTextOk": "* 用户名可以使用",
                    "alertText": "* 这个用户名已经被使用",
                    "alertTextLoad": "* 验证中，请稍等"
                },

                "AjaxUsernameShouldExist": {
                    "url": "/Account/AjaxUsernameShouldExist",
                    "alertText": "* 用户不存在",
                    "alertTextLoad": "* 验证中..."
                },
                "AjaxOrganizationShouldntExist": {
                    "url": "/Organization/IsOrganizationNotExist",
                    "extraData": "",
                    "alertTextOk": "* 单位名称可以使用",
                    "alertText": "* 单位名称已经被使用",
                    "alertTextLoad": "* 验证中，请稍等"
                },
                "AjaxAwardShouldntExist": {
                    "url": "/Award/IsAwardNotExist",
                    "extraData": "",
                    "alertTextOk": "* 奖项名称可以使用",
                    "alertText": "* 奖项名称已经被使用",
                    "alertTextLoad": "* 验证中，请稍等"
                }
            };

        }
    };
    $.validationEngineLanguage.newLang();
})(jQuery);